﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetDon.WebControls;
using NetDon.eBoss.Data.EntityClasses;

namespace NetDon.OA.Portal.HtmlTool
{
    public partial class eBayCategoryEdit :  NetDonPage
    {
        #region Properties
        protected int Id
        {
            get
            {
                return Parameters.GetInt32("Id");
            }
        }

        public string Type
        {
            get { return Parameters.GetString("Type"); }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {


            if (!IsPostBack)
            {

                CancelButton = btnReturn;
                BindDropDownLists();
                if (Id > 0)
                {

                    var template = new HtmltoolcategoryruleEntity();
                    template.FetchUsingPK(Id);
                    panelCustomInfo.DataSource = template;
                    panelCustomInfo.DataBind();
                    if(txtRule.Text.Trim()=="默认")
                    {
                        txtRule.Enabled = false;
                    }
                }


            }
        }



        private void BindDropDownLists()
        {

        }




        private bool save()
        {
            HtmltoolcategoryruleEntity entity = null;
            if (Id > 0)
            {
                entity = new HtmltoolcategoryruleEntity(Id);

            }
            else
            {
                entity = new HtmltoolcategoryruleEntity();
            }
            entity.Rule = txtRule.Text.Trim();
            entity.Category = txtCategory.Text.Trim();
            entity.Ebaycategory = txtEbaycategory.Text.Trim();
            entity.Save();
            return true;
        }


        protected void btnSave_Click(object sender, EventArgs e)
        {

            if (save())
            {
                Success("保存成功!");
                CloseWindow(true);
            }



        }




    }

}